<?php
$db = include 'dbConnect.php';
$test = array('foo'=>'bar', 'bar'=>'foo');
$sql = 'SELECT * FROM device';
$result = mysql_query( $sql ) or die("Couldn't execute query.".mysql_error()); 
// echo "<pre>\n";
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
    // print_r($row);
    $row['mac'] = 'hidden';
    $row['serial'] = 'hidden';
    $device[] = $row;
}
header('Content-type: application/json');
$test['data'] = $device;
echo json_encode($test);
// echo "</pre>\n";
?>